##set up a test dataset using internal functions
##should label sample_1 as ACC and EXP and samples 2 and 3 as UNK
##sample_3 should be too divergent from the expected 150 rows, so
##the inferred labels should remain 'UNK'
samples=c(NA, "sample_1", NA, "sample_1", "sample_2", "sample_3")
count = c(NA,900, NA,150, 150, 110)
measure_break = c(FALSE, FALSE, TRUE, FALSE, FALSE,FALSE)
table_break = c(TRUE, rep(FALSE, length(samples)-1))
phase = rep("D1", length(samples))
err.dta <- data.frame(samples=samples, count=count, measure_break=measure_break, table_break=table_break, phase=phase, stringsAsFactors=FALSE)
sim.bux.lines <- plethy:::generate.sample.buxco(err.dta)
temp.file <- tempfile()
temp.db.file <- tempfile()
write(sim.bux.lines, file=temp.file)
test.bux.db <- parse.buxco(file.name=temp.file, db.name=temp.db.file, chunk.size=10000)
addAnnotation(test.bux.db, query=day.infer.query, index=FALSE)
addAnnotation(test.bux.db, query=break.type.query, index=TRUE)
##quick test of data
test <- proc.sanity(test.bux.db)
head(test$count)
test$time
##get a summary of this
unk.summary <- get.err.breaks(test.bux.db, label.val="UNK")
table(unk.summary$Sample_Name, unk.summary$inferred_labs)
##use the summary to change the Break_type_label column in the annotation table
head(retrieveData(test.bux.db))
adjust.labels(test.bux.db, unk.summary)
head(retrieveData(test.bux.db))
##additional annotations can be added to the database based on sample ID
sample.labels <- data.frame(samples=c("sample_1","sample_3"), response_type=c("high", "low"),stringsAsFactors=FALSE)
add.labels.by.sample(test.bux.db, sample.labels)
final.dta <- retrieveData(test.bux.db)
head(final.dta)
##should be 'high' for sample_1 and 'low' for sample_3 with NAs for sample_2
table(final.dta$Sample_Name, final.dta$response_type, useNA="ifany")
Run the code above in your browser using DataLab